package com.ruoyi.web.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.MesFactory;
import com.ruoyi.system.service.IMesFactoryService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * editFactoryController
 * 
 * @author ruoyi
 * @date 2022-07-14
 */
@RestController
@RequestMapping("/system/editFactory")
public class MesFactoryController extends BaseController
{
    @Autowired
    private IMesFactoryService mesFactoryService;

    /**
     * 查询editFactory列表
     */
    @PreAuthorize("@ss.hasPermi('system:editFactory:list')")
    @GetMapping("/list")
    public TableDataInfo list(MesFactory mesFactory)
    {
        startPage();
        List<MesFactory> list = mesFactoryService.selectMesFactoryList(mesFactory);
        return getDataTable(list);
    }

    /**
     * 导出editFactory列表
     */
    @PreAuthorize("@ss.hasPermi('system:editFactory:export')")
    @Log(title = "editFactory", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MesFactory mesFactory)
    {
        List<MesFactory> list = mesFactoryService.selectMesFactoryList(mesFactory);
        ExcelUtil<MesFactory> util = new ExcelUtil<MesFactory>(MesFactory.class);
        util.exportExcel(response, list, "editFactory数据");
    }

    /**
     * 获取editFactory详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:editFactory:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(mesFactoryService.selectMesFactoryById(id));
    }

    /**
     * 新增editFactory
     */
    @PreAuthorize("@ss.hasPermi('system:editFactory:add')")
    @Log(title = "editFactory", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MesFactory mesFactory)
    {
        return toAjax(mesFactoryService.insertMesFactory(mesFactory));
    }

    /**
     * 修改editFactory
     */
    @PreAuthorize("@ss.hasPermi('system:editFactory:edit')")
    @Log(title = "editFactory", businessType = BusinessType.UPDATE)
    @PostMapping("/updateMesFactory")
    public AjaxResult edit(@RequestBody MesFactory mesFactory)
    {
        return toAjax(mesFactoryService.updateMesFactory(mesFactory));
    }

    /**
     * 删除editFactory
     */
    @PreAuthorize("@ss.hasPermi('system:editFactory:remove')")
    @Log(title = "editFactory", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(mesFactoryService.deleteMesFactoryByIds(ids));
    }
}
